package cn.yj.relay.core.mapper;

import cn.yj.relay.core.entity.Task;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 永健
 * @since 2020-03-03 17:41
 */
public interface TaskMapper extends BaseMapper<Task>
{
    List<Task> findList(@Param("map") Map<String, Object> map, @Param("page") Page<Task> page);


    @Select("select ifnull(sum(s.royalty_money),0) from tb_task s where s.emp_id=#{empId}")
    Double selectSumRoyaltyMoney(Integer empId);

    @Select("select ifnull(sum(s.all_money),0) as allMoney from tb_task s where s.emp_id=#{empId}")
    Double selectSumAllMoney(Integer empId);

    double countAll(@Param("map") Map<String, Object> map);

    // @Select(value = "SELECT SUM(royalty_money) as royaltyMoney,emp_id empId,emp_name empName,emp_phone empPhone from tb_task WHERE create_time >=#{startTime} and create_time <= #{endTime} and emp_id=#{empId} GROUP BY emp_id,emp_name,emp_phone ")
    List<Map<String, Object>> sumEmpRoYalMoney(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("empId") Integer empId);
}
